package com.treehouse.gui.loaderview.viewComp;

import javax.swing.JProgressBar;
import javax.swing.table.AbstractTableModel;

public class ActorScenesTableModel extends AbstractTableModel {

	private static final long serialVersionUID = 526613934960383373L;
	private String[] columns = new String[0];
	private Object[][] rows = new Object[0][0];
	
	public ActorScenesTableModel() {

	}

	@Override
	public int getRowCount() {
		return this.rows.length;
	}

	@Override
	public int getColumnCount() {
		return this.columns.length;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return this.rows[rowIndex][columnIndex];
	}
	
	@Override
	public boolean isCellEditable(int rowIndex, int columnIndex){
		if(columnIndex == 3) return true;
		else return false;
	}
	
	@Override
    public void setValueAt(Object value, int row, int col) {
		if(col >= 3){
			((JProgressBar)this.rows[row][col]).setValue(Integer.parseInt((String)value));
		}
		else
        this.rows[row][col] = value;
        fireTableCellUpdated(row, col);
    }
    
    @Override
    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }
	

	public String[] getColumns() {
		return columns;
	}

	public void setColumns(String[] columns) {
		this.columns = columns;
		this.fireTableStructureChanged();
	}

	public Object[][] getRows() {
		return rows;
	}

	public void setRows(Object[][] rows) {
		this.rows = rows;
		this.fireTableDataChanged();
	}
	
	@Override
	public String getColumnName(int column){
		return this.columns[column];
	}
	
	
	


}
